package com.yunfei.api.v2;

import com.yunfei.api.v2.contants.ProdConfTemplateContants;
import com.yunfei.api.v2.param.MagerIdParam;
import com.yunfei.api.v2.param.prodConfTemplate.ProdConfTemplateUpdateParam;
import com.yunfei.api.v2.result.createTemplate.CreateTemplateJsonRootBean;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.ResultStatus;
import com.yunfei.service.RedisService;
import com.yunfei.utils.string.StringUtil;
import com.yunfei.yunhetong.magerContDtl.bo.MagerContDtlBo;
import com.yunfei.yunhetong.magerContDtl.service.MagerContDtlService;
import com.yunfei.yunhetong.prodInfoDtl.bo.ProdInfoDtlBo;
import com.yunfei.yunhetong.prodInfoDtl.service.ProdInfoDtlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 产品配置模板相关接口
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/api/v2/prodConfTemplate")
@Api(value = ProdConfTemplateContants.NAMESPACE,tags =  ProdConfTemplateContants.NAMESPACE )
public class ProdConfTemplateApiController {

    @Autowired
    private RedisService redisService;
    @Autowired
    private MagerContDtlService magerContDtlService;
    @Autowired
    private ProdInfoDtlService prodInfoDtlService;

    /**
     * @Description: 根据管理人id获取已配置模板列表
     * @Author: zhengyunfei
     * @Date: 2019/7/29
     * @time:10:30
     */
    @PostMapping(value="/list")
    @ApiOperation(position = 3,value = ProdConfTemplateContants.list,notes = ProdConfTemplateContants.list,response = CreateTemplateJsonRootBean.class)
    public Object list(MagerIdParam param){
        ResultModel resultModel=new ResultModel();
        try{
            String crmMagerId=param.getCrmMagerId();
            Map<String,Object> queryMap=new HashMap<>();
            queryMap.put("crmMagerId",crmMagerId);
            List<MagerContDtlBo> list=magerContDtlService.findAllList(queryMap);
            resultModel.setData(list);
            resultModel.setCode(ResultStatus.SUCCESS.getCode());
            resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        }catch (Exception e){
            resultModel.setCode(ResultStatus.ERROR.getCode());
            resultModel.setMessage(ResultStatus.ERROR.getMessage());
            e.printStackTrace();
        }

        return resultModel;
    }

}
